package com.starchen.optimalselection.admin.controller;

import com.starchen.optimalselection.admin.service.FileService;
import com.starchen.optimalselection.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author daxilong
 * @date 2025/2/26 15:30
 */
@Api(value = "上传管理接口")
@RestController
@RequestMapping("/admin/file")
public class FileUploadController {

    @Autowired
    private FileService fileService;

    @ApiOperation("上传文件接口")
    @PostMapping("/upload")
    public Result<String> upload(@RequestPart("file") MultipartFile file) {
        String url = fileService.upload(file);
        return Result.success(url);
    }

    @ApiOperation("上传文件接口")
    @PostMapping("/mulupload")
    public Result mulupload(@RequestPart("file") MultipartFile[] file) {
        String[] url = fileService.mulupload(file);
        return Result.success(url);
    }

}
